<?php
session_start();
if (isset($_POST['openid']) && !empty($_POST['openid'])){
    include '../c/config.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $openid=addslashes(trim($_POST['openid']));
    $qname=addslashes(trim($_POST['qname']));
    $wid=addslashes(trim($_POST['wid']));
    $qiuhao=addslashes(trim($_POST['qhaoid']));

    $query=$mysqli->query("SELECT id FROM joinqiu where openid='".$openid."' and qiuid='".$qname."'  limit 0,1 ");
    if($query->num_rows>0){
       
    }else{
        $queryQiu=$mysqli->query("SELECT openid FROM qdui where id='".$qname."' limit 0,1 ");
        if($queryQiu->num_rows>0){
            $getQiu=$queryQiu->fetch_assoc();
            $qiuOpenid=$getQiu['openid'];
            //通知队长
            $mysqli->query("insert into message(myid,fromid,type,createtime) values('".$qiuOpenid."','".$openid."','1','".date("Y-m-d H:i:s")."')  ");
        }
        $mysqli->query("insert into joinqiu(openid,qiuhao,qiuid,weizhi,createtime) values('".$openid."','".$qiuhao."','".$qname."','".$wid."','".date("Y-m-d H:i:s")."')  ");
        $mysqli->query("insert into joinqiu_log(openid,qiuhao,qiuid,weizhi,createtime) values('".$openid."','".$qiuhao."','".$qname."','".$wid."','".date("Y-m-d H:i:s")."')  ");
    }
    $mysqli->close();
    
    echo json_encode(array('s'=>'y'));
}

